#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int Min(int* left, int* right)
{
    int min = *left < *right ? *left : *right;
    return min;
}
int main()
{
    int height[] = {1, 8, 6, 2, 5, 4, 8, 3, 7};
    int heightSize = sizeof(height) / sizeof(height[0]);
    int* left = height;
    int* right = height + heightSize - 1;
    int ret = 0;
    while (left < right)
    {
        int min = Min(left, right);
        int mid = (int)(right - left);
        if (min * mid > ret)
        {
            ret = min * mid;
        }
        if ((Min(left + 1, right)) > (Min(left, right + 1)))
            left++;
        else
            right--;
    }
    printf("%d\n", ret);
    return 0;
}